<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>04-mapState-辅助函数</title>
    </head>
    <body>
        <div id="app">
            {{count}}
            <button @click="change">修改 state的值</button>
        </div>
        <script src="../js/vue.js"></script>
        <script src="../js/vuex.js"></script>
        <script>
            let mapState=Vuex.mapState;
            let store=new Vuex.Store({
                state:{
                    count:10
                },
                mutations:{
                    changeCount(state){
                        state.count++;
                    }
                }
            })

            let vm=new Vue({
                el:"#app",
                data:{},
                store,
                computed:{
                    ...mapState(['count']),
                },
                methods:{
                    change(){
                        this.$store.commit("changeCount");
                    }
                }
            })
            console.log(vm);
        </script>
    </body>
</html>